#include "ApprenticeOwnedStates.h"
#include "State.h"
#include "Apprentice.h"
#include "Locations.h"

#include <iostream>
using std::cout;


////////////////////////////////////////////////////
/////////////////Oasis and Bask/////////////////////
////////////////////////////////////////////////////

VisitOasisAndBask* VisitOasisAndBask::Instance()
{
	static VisitOasisAndBask instance;

	return &instance;
}

void VisitOasisAndBask::Enter(Apprentice* pApprentice)
{

	if(pApprentice->funcLocation() != Oasis)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Going to the Oasis.";

		pApprentice->ChangeLocation(Oasis);
	}
}



void VisitOasisAndBask::Execute(Apprentice* pApprentice)
{  
	if(pApprentice->Uncomfortable())
	{

		pApprentice->DecreaseDiscomfort();
		pApprentice->IncreaseThirst();
		pApprentice->IncreaseFatigue();

		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: That was a good rest.";
		pApprentice->InputMessage("Went to Rest");
	}
	cout << "\nLast Turn My Master : " << pApprentice->OutputMasterMessage();

	pApprentice->FindActivity(); //Makes the Character figure out what he should do next.

}

void  VisitOasisAndBask::Exit(Apprentice* pApprentice)
{
	if(pApprentice->pStateMachine->CurrentState() != VisitOasisAndBask::Instance())
	{
	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Well, that was relaxing, now to my other matters.";
	}
}


////////////////////////////////////////
//////////////////Drink/////////////////
////////////////////////////////////////

VisitOasisAndDrinkApp* VisitOasisAndDrinkApp::Instance()
{
	static VisitOasisAndDrinkApp instance;

	return &instance;
}


void VisitOasisAndDrinkApp::Enter(Apprentice* pApprentice)
{
	if(pApprentice->funcLocation() != Oasis)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Going to the Oasis.";

		pApprentice->ChangeLocation(Oasis);
	}
}



void VisitOasisAndDrinkApp::Execute(Apprentice* pApprentice)
{  
	if(pApprentice->Thirsty())
	{

		pApprentice->DecreaseThirst();
		pApprentice->IncreaseDiscomfort();
		pApprentice->IncreaseHunger();

		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: That's some good water.";
		pApprentice->InputMessage("Got some water");
	}
	cout << "\nLast Turn My Master : " << pApprentice->OutputMasterMessage();


	pApprentice->FindActivity(); //Makes the Apprentice figure out what he should do next.

}

void  VisitOasisAndDrinkApp::Exit(Apprentice* pApprentice)
{
	if(pApprentice->pStateMachine->CurrentState() != VisitOasisAndDrinkApp::Instance())
	{
	//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
	cout << "\nApprentice: Well, that was refreshing, now to my other matters.";
	}
}


/////////////////////////
///////////Sleep/////////
/////////////////////////
VisitTreetopsAndSleep* VisitTreetopsAndSleep::Instance()
{
	static VisitTreetopsAndSleep instance;

	return &instance;
}

void VisitTreetopsAndSleep::Enter(Apprentice* pApprentice)
{

	if(pApprentice->funcLocation() != Treetops)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Going to the Treetops.";

		pApprentice->ChangeLocation(Treetops);
	}
}



void VisitTreetopsAndSleep::Execute(Apprentice* pApprentice)
{  
	if(pApprentice->Fatigued())
	{
		pApprentice->DecreaseFatigue();
		pApprentice->IncreaseHunger();
		pApprentice->IncreaseThirst();
		cout << "\nApprentice: That was a good Rest";
		pApprentice->InputMessage("Went to Sleep");
	}
	cout << "\nLast Turn My Master : " << pApprentice->OutputMasterMessage();

	pApprentice->FindActivity();

}

void  VisitTreetopsAndSleep::Exit(Apprentice* pApprentice)
{
	if(pApprentice->pStateMachine->CurrentState() != VisitTreetopsAndSleep::Instance())
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Now back to work";
	}
}








/////////////////////////
///////////Hunt//////////
/////////////////////////
VisitJungleAndHunt* VisitJungleAndHunt::Instance()
{
	static VisitJungleAndHunt instance;

	return &instance;
}

void VisitJungleAndHunt::Enter(Apprentice* pApprentice)
{

	if(pApprentice->funcLocation() != Jungle)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Going to the Jungle.";

		pApprentice->ChangeLocation(Jungle);
	}
}



void VisitJungleAndHunt::Execute(Apprentice* pApprentice)
{  
	if(pApprentice->Hungry())
	{
		pApprentice->HuntedReset();
		pApprentice->DecreaseHunger();
		pApprentice->IncreaseFatigue();
		pApprentice->IncreaseThirst();
		cout << "\nApprentice: Killing some boar";
		pApprentice->InputMessage("Went to Hunt");
	}
	cout << "\nLast Turn My Master : " << pApprentice->OutputMasterMessage();


	pApprentice->FindActivity(); //Makes the Apprentice figure out what he should do next.

}

void  VisitJungleAndHunt::Exit(Apprentice* pApprentice)
{
	if(pApprentice->pStateMachine->CurrentState() != VisitJungleAndHunt::Instance())
	{//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Thats enough killing for now.";
	}
}


/////////////////////////////////
///////////////Plau//////////////
/////////////////////////////////

VisitTreetopsAndPlay* VisitTreetopsAndPlay::Instance()
{
	static VisitTreetopsAndPlay instance;

	return &instance;
}

void VisitTreetopsAndPlay::Enter(Apprentice* pApprentice)
{

	if(pApprentice->funcLocation() != Treetops)
	{
		//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Going to the Treetops.";

		pApprentice->ChangeLocation(Treetops);
	}
}



void VisitTreetopsAndPlay::Execute(Apprentice* pApprentice)
{  
	pApprentice->IncreaseFatigue();
	pApprentice->IncreaseHunger();
	pApprentice->IncreaseDiscomfort();
	pApprentice->IncreaseThirst();
	cout << "\nApprentice: Playing some B-Ball";
	pApprentice->InputMessage("Went to Play");
	cout << "\nLast Turn My Master : " << pApprentice->OutputMasterMessage();


	pApprentice->FindActivity();

}

void  VisitTreetopsAndPlay::Exit(Apprentice* pApprentice)
{
	if(pApprentice->pStateMachine->CurrentState() != VisitTreetopsAndPlay::Instance())
	{//SetTextColor(FOREGROUND_BLUE| FOREGROUND_INTENSITY);
		cout << "\nApprentice: Now back to work";
	}
}
